package com.jz.community.moduleshopping.integralGoods.adapter;

import android.graphics.drawable.GradientDrawable;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;

import com.allen.library.SuperButton;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jz.community.basecomm.constant.AppConstants;
import com.jz.community.moduleshopping.R;
import com.jz.community.moduleshopping.integralGoods.bean.IntegralCouponInfo;

import java.util.List;

/**
 * Created by Tony.Fan on 2018/7/3 09:37
 */
public class IntegralCouponAdapter extends BaseQuickAdapter<IntegralCouponInfo.EmbeddedBean.CouponInfoesBean, BaseViewHolder> {


    public IntegralCouponAdapter(@Nullable List<IntegralCouponInfo.EmbeddedBean.CouponInfoesBean> data) {
        super(R.layout.module_shopping_integral_coupon_item_layout, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, IntegralCouponInfo.EmbeddedBean.CouponInfoesBean item) {
        showIntegralGoodsInfo(helper, item);
    }

    private void showIntegralGoodsInfo(BaseViewHolder helper, IntegralCouponInfo.EmbeddedBean.CouponInfoesBean item) {
        SuperButton superButton = helper.getView(R.id.integral_btn);
        GradientDrawable drawable =(GradientDrawable)superButton.getBackground();
        //0 未兑换 1、已兑换
        if (item.getExchange() == 1) {
            drawable.setColor(ContextCompat.getColor(mContext, R.color.gray_light));
        } else {
            drawable.setColor(ContextCompat.getColor(mContext, R.color.integral_coupon_btn_color));
        }
        helper.setText(R.id.integral_money_tv, AppConstants.MONEY + item.getCouponAmount());
        helper.setText(R.id.integral_available_money_tv, item.getCouponName());
        helper.setText(R.id.integral_tv, item.getMinIntegral() + "");
        helper.addOnClickListener(R.id.integral_btn);
    }
}
